/**
 * @filename:ProppbomServiceImpl Dec 14, 2023
 * @project Wonder Vue Admin Api  1.1.0
 * Copyright(c) 2022 Wonder Co. Ltd. 
 * All right reserved. 
 */
package com.wonder.app.service.impl;

import com.wonder.app.domain.Proppbom;
import com.wonder.app.domain.Proppbomlist;
import com.wonder.app.domain.Synbd;
import com.wonder.app.mapper.ProppbomDao;
import com.wonder.app.mapper.ProppbomlistDao;
import com.wonder.app.service.ProppbomService;
import com.wonder.app.request.ProppbomRequest;
import com.wonder.common.utils.DateUtils;
import com.wonder.common.utils.StringUtils;
import com.wonder.common.utils.MessageUtils;
import com.wonder.common.common.AjaxResult;

import java.util.Date;
import java.util.Map;
import java.util.HashMap;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.annotation.AccessType;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;

/**   
 * @Description:TODO(生产用料清单服务实现)
 *
 * @version: 1.1.0
 * @author: Wonder
 * 
 */
@Service
public class ProppbomServiceImpl  extends ServiceImpl<ProppbomDao, Proppbom> implements ProppbomService  {


	@Autowired
	private ProppbomlistDao proppbomlistDao;

    /**
     * 验证生产用料清单信息
     * 
     * @param proppbom
     * @param type
     * @return String
     */
    @Override
    public String validate(Proppbom proppbom,String type){
    
    
       return "";
    }
    
    
    /**
	 * Description:生产用料清单分页返回
	 * @param request //检索条件
	 * @param page //分页参数
	 * @return IPage<Proppbom>   //分页记录
	 */
	@Override 
	public IPage<Proppbom> selectList(ProppbomRequest request, Page<Proppbom> page){
	    LambdaQueryWrapper<Proppbom> lambdaQueryWrapper = new LambdaQueryWrapper<>();
	    
	    if (null != request.getBillNo()) {
	       lambdaQueryWrapper.like(Proppbom::getBillNo, request.getBillNo());
	      }
		if (null != request.getTaskBillNo()) {
			lambdaQueryWrapper.like(Proppbom::getTaskBillNo, request.getTaskBillNo());
		}

		if (null != request.getCreateTime()){
			Date[] createTime = request.getCreateTime();
			if(createTime.length > 0)
				lambdaQueryWrapper.ge(Proppbom::getCreateDate, createTime[0]);
			if(createTime.length == 2)
				lambdaQueryWrapper.le(Proppbom::getCreateDate, DateUtils.dateToStr(createTime[1],"yyyy-MM-dd") + " 23:59:59");
		}
        
		lambdaQueryWrapper.orderByDesc(Proppbom::getId);	
		Page<Proppbom> selectPage = this.baseMapper.selectPage(page, lambdaQueryWrapper);
		return selectPage;
    }

	@Override
	public List<Proppbomlist> getppbomList(String billNo) {

		return proppbomlistDao.selectList(new QueryWrapper<Proppbomlist>().eq("billNo",billNo));
	}


}